package org.yys.seata.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.yys.seata.service.AccountService;
import org.yys.seata.service.AccountTCCService;

@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private AccountService accountService;

    @Autowired
    private AccountTCCService accountTCCService;

    @GetMapping("/decrease")
    public String descrese(@RequestParam("userId") Long userId,
                           @RequestParam("money") Integer money){

        accountTCCService.tryDecrease(userId,money);

        return "success";
    }
}
